package com.lin.activity;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.TextView;
import cn.sharesdk.tencent.qq.QQ;
import cn.sharesdk.tencent.weibo.TencentWeibo;
import cn.sharesdk.wechat.friends.Wechat;
import cn.sharesdk.wechat.moments.WechatMoments;

import com.lin.utils.ShareListener;
import com.lin.utils.Utils;
import com.lin.views.QRCodeBitmapView;
import com.ly.quickdev.library.activity.DevBaseActivity;
import com.yunfeng.supercall.R;
import com.yunfeng.supercall.activity.BaseActivity;
import com.yunfeng.supercall.bean.Constants;
import com.yunfeng.supercall.bean.UserBean;

public class QRCodeCreateActivity extends Activity implements OnClickListener {

	private ImageView mImageView;
	private TextView mTextViewUserName;
	// private FrameLayout mFrameLayoutBack;
	private ImageView mImageViewBack;
	private TextView mTextViewShare;

	private Bitmap bitmap;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);

		setContentView(R.layout.activity_qrcode);
		QRCodeBitmapView mView = (QRCodeBitmapView) findViewById(R.id.qrcode_scanner);

		mImageView = (ImageView) findViewById(R.id.qrcode_photo);
		Intent intent = getIntent();
		if (intent != null) {
			mImageView.setImageBitmap((Bitmap) intent
					.getParcelableExtra("avatar"));
			mImageView.setOnClickListener(this);
		}

		// mFrameLayoutBack = (FrameLayout) findViewById(R.id.framelayout_back);
		mTextViewUserName = (TextView) findViewById(R.id.textview_username);
		UserBean mUser = BaseActivity.getUser(this);
		// bitmap = mView.createBitmap(mUser.getPhone());
		mView.setBitmap(QRCodeBitmapView.createBitmap(this));
		mTextViewUserName.setText(mUser.getNick_name());

		// mFrameLayoutBack.setOnClickListener(this);
		mImageViewBack = (ImageView) findViewById(R.id.imageview_back);
		mTextViewShare = (TextView) findViewById(R.id.textview_share);
		mImageViewBack.setOnClickListener(this);
		mTextViewShare.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.imageview_back:
			finish();
			break;
		case R.id.textview_share:
			View content = getLayoutInflater().inflate(R.layout.dialog_share,
					null);
			DevBaseActivity.getDialog(this, content, null);
			Utils.setUpImage(this, content);
			break;
		case R.id.qrcode_photo:
			if (mImageView.getVisibility() != View.GONE) {
				mImageView.startAnimation(AnimationUtils.loadAnimation(this,
						R.anim.zoom_out));
				mImageView.setVisibility(View.GONE);
			}
			break;
		}
	}

	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
		sendBroadcast(new Intent(Constants.ACTION_NEWFRIEND_MSG));

	}
	
	
}